var config = require('../../config');
var whost = config.whost;
var request = require('../../support').request2;

/**
 * 列举楼栋列表
 * @return promise
 */
exports.listBuilding = function (context, projectId, groupCode) {
  return request(context, {
    url: whost + '/hk-api/api/json/brick/getBuildings',
    data: {
      projectId: projectId,
      groupCode: groupCode || null,
    }
  });
};

/**
 * 列举房间列表
 * @return promise
 */
exports.listRoom = function (context, buildingId) {
  return request(context, {
    url: whost + '/hk-api/api/json/brick/getRooms',
    data: {
      buildingId: buildingId,
    }
  });
};

/**
 * 获取房间
 * @return promise
 */
exports.getRoom = function (context, roomId) {
  return request(context, {
    url: whost + '/hk-api/api/json/brick/getRoom',
    data: {
      roomId: roomId,
    }
  });
};

/**
 * 生成绑定房间二维码
 * @return promise
 */
exports.quickmark = function (context, roomId, identity, puserId) {
  return request(context, {
    url: whost + '/hk-api/api/json/room/hkBindRoomQuickmark',
    data: {
      roomId: roomId,
      puserId: puserId,
      hkIndentity: identity, // hkIndentity[身份][业主:1,家庭成员:2,租客:4][Integer]:[不能为空]
    }
  });
};

/**
 * 绑定记录
 * @return promise
 */
exports.listBinds = function (context, puserId, page, size) {
  return request(context, {
    url: whost + '/hk-api/api/json/room/getBindRecord',
    data: {
      puserId: puserId,
      status: 1,
      pageNo: page || 1,
      pageSize: size || 20,
    }
  });
};